package com.task.manager.mapper;

import com.task.manager.domain.Lock;
import org.apache.ibatis.jdbc.SQL;

public class LockSqlProvider {

    public String insertSelective(Lock record) {
        SQL sql = new SQL();
        sql.INSERT_INTO("t_lock");
        
        if (record.getLockCode() != null) {
            sql.VALUES("LOCK_CODE", "#{lockCode,jdbcType=VARCHAR}");
        }
        
        if (record.getLockTime() != null) {
            sql.VALUES("LOCK_TIME", "#{lockTime,jdbcType=BIGINT}");
        }
        
        if (record.getExpTime() != null) {
            sql.VALUES("EXP_TIME", "#{expTime,jdbcType=BIGINT}");
        }
        
        return sql.toString();
    }

    public String updateByPrimaryKeySelective(Lock record) {
        SQL sql = new SQL();
        sql.UPDATE("t_lock");
        
        if (record.getLockTime() != null) {
            sql.SET("LOCK_TIME = #{lockTime,jdbcType=BIGINT}");
        }
        
        if (record.getExpTime() != null) {
            sql.SET("EXP_TIME = #{expTime,jdbcType=BIGINT}");
        }
        
        sql.WHERE("LOCK_CODE = #{lockCode,jdbcType=VARCHAR}");
        
        return sql.toString();
    }
}